<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<!DOCTYPE html>
<html>
<head>

<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="css/BSindex.css" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script src="js/BSindex.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
</head>
<script type="text/javascript">
	
	$(function(){
		var  usernameflag=false,emailflag=false,telflag=false,passwordflag=false;
		
		$("#username").focus(function(){
			
			$("#usernamelab").hide();
			
		});
		// 邮箱  获取焦点
		$("#email").focus(function(){
			
			$("#emaillab").hide();
		});
		
		$("#tel").focus(function(){
			
			$("#tellab").hide();
		});
		$("#password").focus(function(){
			
			$("#passwordlab").hide();
		});
		$("#password").blur(function(){
			var  password =  $("#password").val();
			if(password==""){
				$("#passwordlab").text("不填写表示不修改");
				$("#passwordlab").css("color","red");
				$("#passwordlab").show();
				
				
			}else{
				$("#passwordlab").text("可以用");
				$("#passwordlab").css("color","#abcdef");
				$("#passwordlab").show();
				
			}
			passwordflag = true ;
			
		});
		//手机  丢失焦点
				$("#tel").blur(function(){
					var  tel =  $("#tel").val();
					if(tel==""){
						$("#tellab").text("不填写表示不修改");
						$("#tellab").css("color","red");
						$("#tellab").show();
						
						telflag  =true ;
						
						return  ;
					}		
					$.ajax({
						cache:false,
						async: false,
						type: "post",
						dataType: "json",
						data:{"key":"tel","tel":tel},
						url:"/fruits/admin/AdminVerifyServlet",
						success: function(res){
							if(res==true){
								$("#tellab").text("可以用");
								$("#tellab").css("color","#abcdef");
								$("#tellab").show();
								telflag = true ;
							}
							if(res==false){
								$("#tellab").text("已存在");
								$("#tellab").css("color","#ff9900");
								$("#tellab").show();
							}
						}
					});
				});
		
		
		
		
		//邮箱  丢失焦点
		$("#email").blur(function(){
			var  email =  $("#email").val();
			if(email==""){
				$("#emaillab").text("不填写表示不修改");
				$("#emaillab").css("color","red");
				$("#emaillab").show();
				emailflag  =true ;
				return  ;
			}		
			$.ajax({
				cache:false,
				async: false,
				type: "post",
				dataType: "json",
				data:{"key":"email","email":email},
				url:"/fruits/admin/AdminVerifyServlet",
				success: function(res){
					if(res==true){
						$("#emaillab").text("可以用");
						$("#emaillab").css("color","#abcdef");
						$("#emaillab").show();
						emailflag  = true;
					}
					if(res==false){
						$("#emaillab").text("已存在");
						$("#emaillab").css("color","#ff9900");
						$("#emaillab").show();
					}
				}
			});
		});

		
		
		$("#username").blur(function(){
			
			var   username =  $("#username").val();
			
			if(username==""){
				$("#usernamelab").text("不填写表示不修改");
				$("#usernamelab").css("color","red");
				$("#usernamelab").show();
				usernameflag=true ;
				return  ;
			}
			$.ajax({
				cache: false,
				async: false,
				type: "post",
				dataType: "json",
				data: {"username":username,"key":"username"},
				url:"/fruits/admin/AdminVerifyServlet",
				success: function(res){
					if(res==true){
						$("#usernamelab").text("可以用");
						$("#usernamelab").css("color","#abcdef");
						$("#usernamelab").show();
						usernameflag  =  true ;
						
					}
					if(res==false){
						$("#usernamelab").text("已存在");
						$("#usernamelab").css("color","#ff9900");
						$("#usernamelab").show();
					}
				}		
			});

		});
		////   btn
		$("#btn").click(function(){
			var   flag =  usernameflag&&emailflag&&telflag&&passwordflag;
			if(flag){
				var   frm  =   $("#frm");
				
				frm.submit();
				
				/* var   uid =  $("#uid").val();
				var   username =  $("#username").val();
				var   email  =  $("#email").val();
				var   tel =  $("#tel").val();
				var   password=$("#password").val();
				 */
				
				//location.href="/fruits/admin/AdminChangeUserServlet?......."
				
			}else{
				alert("页面上有错误，请完善!");
			}
			
		});
		
		
	});

</script>
<body>
	<div class="mean">
		<div class="logo">
			<a href="index.jsp"><img src="img/alogo.png" alt="" /></a>
		</div>
		<div class="mean_ul">
			<div class="mean_li" onclick="sss('u')">用户管理</div>
			<div class="user_list" id="user_list">
				<div class="mm">
					<a href="/fruits/admin/AdminShowAllUsersServlet">全部用户</a>
				</div>
				<div class="mm">
					<a href="BSindex2.jsp">添加用户</a>
				</div>
			</div>
			<div class="mean_li" onclick="sss('f')">商品管理</div>
			<div class="fruit_list" id="fruit_list">
				<div class="mm"><a href="/fruits/admin/AdminShowAllGoodsServlet?pageNum=1">库存水果</a></div>
      			<div class="mm"><a href="/fruits/admin/AdminShowAllHotGoodsServlet?pageNum=1">热卖水果</a></div>
				<div class="mm">
					<a href="BSindex5.jsp">水果入库</a>
				</div>
			</div>
		</div>
	</div>


	<div class="gong" id="x3">
		<div class="con">

			<div class="form">
				<form  action="/fruits/admin/AdminChangeUserServlet" method="post"   id="frm">
					<input  type="hidden"   name="uid"   value="${thisuser.uid}"   id="uid">
					<div class="add">
						<span class="add_tit">用户名 ：</span> <span class="add_text">
							<input type="text" name="username" id="username"
							value="${thisuser.username}" /> <label id="usernamelab"></label>
						</span>

					</div>

					<div class="add">
						<span class="add_tit">邮箱 ：</span> <span class="add_text"><input
							type="text" name="email" id="email" value="${thisuser.email}" /></span>
						<label id="emaillab"></label>
					</div>

					<div class="add">
						<span class="add_tit">手机 ：</span> <span class="add_text"><input
							type="text" name="tel" id="tel" value="${thisuser.tel}" /></span> <label
							id="tellab"></label>
					</div>

					<div class="add">
						<span class="add_tit">密码 ：</span> <span class="add_text"><input
							type="text" name="password" id="password"
							value="${thisuser.password}" /></span> <label id="passwordlab"></label>
					</div>
					<div class="add_sublmit">
						<input type="button" value="保存"  id="btn" />
					</div>
				</form>
			</div>
		</div>
	</div>




</body>
</html>

